// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SourceFile

package com.sgame.android.social;

import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import com.sgame.android.data.UserData;
import com.sgame.android.lang.AppVersion;
import com.sgame.android.lang.Error;
import com.sgame.android.lang.ErrorMap;
import com.sgame.android.social.IMobageHttpResponseHandler;
import com.sgame.android.social.InvalidConfigurationException;
import com.sgame.android.data.MBUUser;
import com.sgame.android.data.SessionData;
import com.sgame.android.data.SystemMessage;
import com.sgame.android.network.CacheDisk;
import com.sgame.android.network.HttpRequest;
import com.sgame.android.network.ISgameHttpClientFactory;
import com.sgame.android.network.MakeSgameHttpClient;
import com.sgame.android.network.AsyncHttpResponseHandler;
import com.sgame.android.network.StringNameValueMap;
import com.sgame.android.network.ISgameHttpClient;
import com.sgame.android.network.SgameHttpClient;
import com.sgame.android.network.HttpResponseHandler;
import com.sgame.android.network.InvalidCredentialsConfigurationException;
import com.sgame.android.network.Credentials;
import com.sgame.android.network.util.MakeCmdUrl;
import com.sgame.android.MLog;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import org.apache.http.client.CookieStore;
import org.apache.http.impl.client.BasicCookieStore;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public final class Connection
{
    private static String Encode(String s)
    		throws NoSuchAlgorithmException, UnsupportedEncodingException
    {
    	MessageDigest encode;
        encode = MessageDigest.getInstance("SHA-1");
        encode.update(s.getBytes("iso-8859-1"), 0, s.length());
        byte [] bytes = encode.digest();
        StringBuilder sb = new StringBuilder();
        int i1 = bytes.length;
        for(int j1 = 0; j1 < i1; j1++)
        {
            byte byte0;
            int k1 = (byte0 = bytes[j1]) >>> 4 & 0xf;
            int l1 = 0;
            do
            {
            	sb.append(k1 < 0 || k1 > 9 ? (char)(97 + (k1 - 10)) : (char)(48 + k1));
                k1 = byte0 & 0xf;
            } while(l1++ <= 0);
        }

        return sb.toString();
    }

    class RequestHandler implements IRequestHandler
    {

        public final void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore)
        {
        	mHandler.onComplete(sessiondata, credentials, cookiestore);
        }

        public final void onError(Error error)
        {
            MLog.d(Connection.getTAG(), "Failed to reestablish guest user session, try again with stored username and password.");
            mHandler.onError(error);
        }

        public final void onComplete()
        {
        	mHandler.onComplete();
        }

        IRequestHandler getHandler(RequestHandler a1)
        {
            return a1.mHandler;
        }

        private IRequestHandler mHandler;
        private String mData1;
        private String mData2;
        final Connection mConnection;

        RequestHandler(IRequestHandler d1, String s, String s1)
        {
        	mConnection = Connection.this;
            mHandler = d1;
            mData1 = s;
            mData2 = s1;
        }
    }

    private class Register implements Runnable
    {

        public final void run()
        {
        	IRequestHandlerStringData c1;
            HttpRequest httprequest;
            JSONObject jsonobject;
            JSONObject obj;
            c1 = new IRequestHandlerStringData() {

                public final void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore)
                {
                    if(mUserData != null && mUserData.length() > 0)
                        MBUUser.setPassword(Connection.getContext(mRegister.mConnection), mUserData);
                    mRegister.mHandler.onComplete(sessiondata, credentials, cookiestore);
                    Connection.Finish(mRegister.mConnection, mRegister);
                }

                public final void onError(Error error)
                {
                	mRegister.mHandler.onError(error);
                    Connection.Finish(mRegister.mConnection, mRegister);
                }

                public final void onComplete()
                {
                	mRegister.mHandler.onComplete();
                    Connection.Finish(mRegister.mConnection, mRegister);
                }

                public final void setData(String s2)
                {
                	mUserData = s2;
                }

                private String mUserData;
                final Register mRegister;

                
                {
                	mRegister = Register.this;
                	mUserData = null;
                }
            }
            ;
            httprequest = Connection.createHttpRequest(mConnection, false, null);
            jsonobject = new JSONObject();
            obj = new JSONObject();
            String s = android.provider.Settings.Secure.getString(Connection.getContext(mConnection).getContentResolver(), "android_id");
            try
            {
				s = Encode((new StringBuilder()).append(s).append(System.currentTimeMillis()).toString()).substring(0, 16);
	            c1.setData(s);
	            jsonobject.put("password", s);
	            jsonobject.put("password_confirmation", s);
	            jsonobject.put("lite", true);
	            jsonobject.put("age_restricted", false);
	            obj.put("user", jsonobject);
	            httprequest.setBody(new com.sgame.android.network.util.JsonString(((JSONObject) (obj)).toString()));
	            httprequest.setMethod("POST");
			} catch (NoSuchAlgorithmException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            catch(JSONException ex)
            {
            }
            CookieStore cookieStore = new BasicCookieStore();
            SgameHttpClient g1;
			try {
				g1 = Connection.createSgameHttpClient(mConnection, cookieStore);
	            String s1 = MakeCmdUrl.registerUser(Connection.d(mConnection), Connection.getAppKey(mConnection));
	            g1.setUrl(s1);
	            g1.Execute(httprequest, Connection.createRequest(mConnection, Connection.createRequestHandlerWithJson(mConnection, c1), cookieStore));
			} catch (InvalidCredentialsConfigurationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            return;
        }

        IRequestHandler mHandler;
        final Connection mConnection;

        public Register(IRequestHandler d1)
        {
            super();
            mConnection = Connection.this;
            mHandler = d1;
        }
    }

    private class CloseHandler implements Runnable
	{
	
	    public final void run()
	    {
	        Connection.getCredentials(mCurrent).clearTokens();
	        Connection.deleteCredentials(mCurrent);
	        for(Iterator<IReleaseHandler> iterator = Connection.getListReleaseHandler(mCurrent).iterator(); iterator.hasNext(); ((IReleaseHandler)iterator.next()).Close());
	        Connection.Finish(mCurrent, this);
	    }
	
	    final Connection mCurrent;
	
	    private CloseHandler()
	    {
	    	mCurrent = Connection.this;
	    }
	
	    CloseHandler(byte byte0)
	    {
	        this();
	    }
	}

    private class Login implements Runnable
    {

        public final void run()
        {
        	final IRequestHandlerWithError f1 = new IRequestHandlerWithError() {

                public final void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore)
                {
                	_Login.mHandler.onComplete(sessiondata, credentials, cookiestore);
                    Connection.Finish(_Login.mConnection, _Login);
                }

                public final void onError(Error error)
                {
                	_Login.mHandler.onError(error);
                    Connection.Finish(_Login.mConnection, _Login);
                }

                public final void onComplete()
                {
                	_Login.mHandler.onComplete();
                    Connection.Finish(_Login.mConnection, _Login);
                }

                public final void onError(Error error, UserData userdata)
                {
                	_Login.mHandler.onError(error, userdata);
                    Connection.Finish(_Login.mConnection, _Login);
                }

                final Login _Login;

                
                {
                	_Login = Login.this;
                }
            }
            ;
            MLog.d(Connection.getTAG(), "Login with social account");
            HttpRequest httprequest;
            (httprequest = Connection.createHttpRequest(mConnection, false, null)).addQueryParam("social_token", mSocial.c());
            httprequest.addQueryParam("social_id", mSocial.b());
            httprequest.addQueryParam("email", mEmail);
            httprequest.addQueryParam("social_type", mSocial.a());
            Connection.doRequest(mConnection, httprequest, new IRequestHandlerWithJson() {

                public final void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore)
                {
                	mHandler.onComplete(sessiondata, credentials, cookiestore);
                }

                public final void onError(Error error, JSONObject jsonobject)
                {
                    Connection.getTAG();
                    (new StringBuilder("Login error with data: ")).append(jsonobject).toString();
                    if(error.getCode() == 106)
                    {
                        UserData userdata;
                        (userdata = new UserData()).setEmail(mCurrent.mEmail);
                        try
                        {
                            userdata.setUsername(jsonobject.getString("gamertag"));
                            userdata.setPicture(jsonobject.getString("photo_url"));
                            userdata.setName(jsonobject.getString("fullname"));
                        }
                        // Misplaced declaration of an exception variable
                        catch(Exception ex)
                        {
                            MLog.e(Connection.getTAG(), "Insufficient data");
                        }
                        mHandler.onError(error, userdata);
                        return;
                    }
                    if(error.getCode() == 117)
                    {
                        UserData userdata1;
                        (userdata1 = new UserData()).setEmail(mCurrent.mEmail);
                        mHandler.onError(error, userdata1);
                        return;
                    } else
                    {
                    	mHandler.onError(error);
                        return;
                    }
                }

                final IRequestHandlerWithError mHandler;
                final Login mCurrent;
                
                {
                	mCurrent = Login.this;
                    mHandler = f1;
                }
            }
            		);
        }

        Social mSocial;
        String mEmail;
        String c;
        String d;
        IRequestHandlerWithError mHandler;
        final Connection mConnection;

        public Login(Social d1, String s, String s1, String s2, IRequestHandlerWithError f1)
        {
        	mConnection = Connection.this;
            mSocial = d1;
            mEmail = s;
            c = s1;
            d = s2;
            mHandler = f1;
        }
    }

    private class LoginSgameAccount implements Runnable
    {

        public final void run()
        {
        	IRequestHandler d1 = new IRequestHandler() {

                public final void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore)
                {
                	mCurrent.mHandler.onComplete(sessiondata, credentials, cookiestore);
                    Connection.Finish(mCurrent.mConnection, mCurrent);
                }

                public final void onError(Error error)
                {
                	mCurrent.mHandler.onError(error);
                    Connection.Finish(mCurrent.mConnection, mCurrent);
                }

                public final void onComplete()
                {
                	mCurrent.mHandler.onComplete();
                    Connection.Finish(mCurrent.mConnection, mCurrent);
                }

                final LoginSgameAccount mCurrent;
                {
                	mCurrent = LoginSgameAccount.this;
                }
            }
        	;
            MLog.d(Connection.getTAG(), (new StringBuilder("Login with Username: ")).append(mUserName).append(" - appKey: ").append(Connection.getAppKey(mConnection)).toString());
            HttpRequest httprequest = Connection.createHttpRequest(mConnection, false, null);
            StringNameValueMap b1 = new StringNameValueMap();
            if(mUserName.contains("@"))
                b1.Add("email", mUserName);
            else
                b1.Add("gamertag", mUserName);
            b1.Add("password", mPassword);
            try {
				httprequest.setBody(b1);
			}
            catch (UnsupportedEncodingException e) {
			}
            httprequest.setMethod("POST");
            Connection.doRequest(mConnection, httprequest, Connection.createRequestHandlerWithJson(mConnection, d1));
        }

        String mUserName;
        String mPassword;
        IRequestHandler mHandler;
        final Connection mConnection;

        public LoginSgameAccount(String userName, String pass, IRequestHandler d1)
        {
        	mConnection = Connection.this;
        	mUserName = userName;
        	mPassword = pass;
            mHandler = d1;
        }
    }

    private class GetUserToken implements Runnable
    {

        public final void run()
        {
            IRequestHandler d1 = new IRequestHandler() {

                public final void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore)
                {
                	mCurrent.mHandler.onComplete(sessiondata, credentials, cookiestore);
                    Connection.Finish(mCurrent.mConnection, mCurrent);
                }

                public final void onError(Error error)
                {
                	mCurrent.mHandler.onError(error);
                    Connection.Finish(mCurrent.mConnection, mCurrent);
                }

                public final void onComplete()
                {
                	mCurrent.mHandler.onComplete();
                    Connection.Finish(mCurrent.mConnection, mCurrent);
                }

                final GetUserToken mCurrent;
                
                {
                	mCurrent = GetUserToken.this;
                }
            }
            ;
            boolean flag = false;
            if(Connection.getCredentials(mConnection).hasAuth_Token() || Connection.loadCredentials(mConnection) && Connection.getCredentials(mConnection).hasAuth_Token())
                flag = true;
            if(flag)
            {
                Connection.LoginWithSession(mConnection, Connection.getCredentials(mConnection).getAuth_token(), d1);
                return;
            } else
            {
                d1.onError(new Error(ErrorMap.NO_AUTH_TOKEN));
                return;
            }
        }

        IRequestHandler mHandler;
        final Connection mConnection;

        public GetUserToken(IRequestHandler d1)
        {
            mConnection = Connection.this;
            mHandler = d1;
        }
    }

    public static interface Ib //b
    {

        public abstract void a();

        public abstract void a(Error error);
    }

    public static interface IRequestHandlerWithError extends IRequestHandler
    {

        public abstract void onError(Error error, UserData userdata);
    }

    public static interface IReleaseHandler //e
    {

        public abstract void Close();
    }

    public static interface IRequestHandlerStringData  extends IRequestHandler
    {

        public abstract void setData(String s);
    }

    public static interface IRequestHandler
    {

        public abstract void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore);

        public abstract void onError(Error error);

        public abstract void onComplete();
    }

    private static interface IRequestHandlerWithJson
    {
        public abstract void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore);

        public abstract void onError(Error error, JSONObject jsonobject);
    }


    private synchronized void Finish(Runnable runnable)
    {
        MLog.d(TAG, (new StringBuilder("Finished running command ")).append(runnable.getClass().getSimpleName()).toString());
        m.remove(runnable);
        if(m.size() != 0)
        {
            MLog.d(TAG, (new StringBuilder("Running next command: ")).append(((Runnable)m.get(0)).getClass().getSimpleName()).toString());
            ((Runnable)m.get(0)).run();
            return;
        } else
        {
            MLog.d(TAG, "All commands finished");
            return;
        }
    }

    private synchronized void Run(Runnable runnable)
    {
        MLog.d(TAG, (new StringBuilder("Checking top command ")).append(runnable.getClass().getSimpleName()).toString());
        m.add(runnable);
        if(m.size() > 1)
        {
            MLog.d(TAG, "Stacked command");
            return;
        } else
        {
            MLog.d(TAG, "Running command");
            runnable.run();
            return;
        }
    }

    public Connection(Context context, Credentials credentials, ISgameHttpClientFactory f1, String s, String s1, String s2, String appKey, 
            String appVersion, String sdkVersion, List<IRequestHandler> list, List<IReleaseHandler> list1)
        throws InvalidConfigurationException
    {
        m = new ArrayList();
        c = s;
        mOauthRequestFactory = f1;
        mContext = context;
        i = s2;
        listK = new ArrayList();
        listK.addAll(list);
        listL = new ArrayList();
        listL.addAll(list1);
        MLog.d(TAG, "constructor of USLoginRegHandler called");
        if(credentials != null)
        {
        	mCredentials = (Credentials)credentials.clone();
            if(credentials.getConsumerKey() == null || credentials.getConsumerKey().length() == 0)
                throw new InvalidConfigurationException("Missing consumer key");
            if(credentials.getConsumerSecret() == null || credentials.getConsumerSecret().length() == 0)
            {
                throw new InvalidConfigurationException("Missing consumer secret");
            } else
            {
                d = s1;
                mAppKey = appKey;
                mAppVersion = appVersion;
                mSdkVersion = sdkVersion;
                return;
            }
        } else
        {
            throw new InvalidConfigurationException("Credentials cannot be null");
        }
    }

    private HttpRequest createHttpRequest(boolean flag, StringNameValueMap b1) //a
    {
        HttpRequest httprequest = new HttpRequest();
        TimeZone timezone = TimeZone.getDefault();
        String s;
        if((s = Locale.getDefault().toString()).length() == 0)
        {
            s = "en_US";
            MLog.e(TAG, "Unable to get default locale for this device, using en_US instead");
        }
        if(flag)
        {
            b1.Add("timezone", (new StringBuilder("offset ")).append(timezone.getOffset(15L) / 1000).toString());
            b1.Add("device_type", Build.MODEL);
            b1.Add("os_version", AppVersion.a());
            b1.Add("id", d);
            b1.Add("locale", s);
            try {
				httprequest.setBody(b1);
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        } else
        {
            httprequest.addQueryParam("timezone", (new StringBuilder("offset ")).append(timezone.getOffset(15L) / 1000).toString());
            httprequest.addQueryParam("device_type", Build.MODEL);
            httprequest.addQueryParam("os_version", AppVersion.a());
            httprequest.addQueryParam("id", d);
            httprequest.addQueryParam("locale", s);
        }
        return httprequest;
    }

    private final synchronized void deleteCredentials() //c
    {
        try
        {
            if(CacheDisk.Load(mContext, "__MBG_CREDENTIALS") != null)
                mContext.deleteFile("__MBG_CREDENTIALS");
            return;
        }
        catch(Exception exception)
        {
            MLog.d(TAG, exception.getMessage(), exception);
        }
    }

    private final synchronized boolean loadCredentials() //d
    {
        Object obj;
        try
        {
            if((obj = CacheDisk.Load(mContext, "__MBG_CREDENTIALS")) != null)
            {
            	mCredentials = (Credentials)obj;
                return true;
            }
        }
        catch(Exception exception)
        {
            MLog.d(TAG, exception.getMessage(), exception);
        }
        return false;
    }

    private final synchronized void SaveCredentials()
    {
        try
        {
        	CacheDisk.Save(mContext, "__MBG_CREDENTIALS", mCredentials);
            return;
        }
        catch(IOException ioexception)
        {
            MLog.d(TAG, "Failed to cache data with error - ", ioexception);
        }
    }

    public final void GetUserToken(IRequestHandler d1)
    {
        String s = MBUUser.getNickname(mContext);
        String s1 = MBUUser.getPassword(mContext);
        GetUserToken handler;
        if(s != null && s1 != null && s.length() > 0 && s1.length() > 0)
        {
            MLog.d(TAG, "Trying to reestablish a guest user session.");
            d1 = new RequestHandler(d1, s, s1);
            handler = new GetUserToken(d1);
            Run(handler);
            return;
        } else
        {
            MLog.d(TAG, "Trying to reestablish a non guest user session.");
            handler = new GetUserToken(d1);
            Run(handler);
            return;
        }
    }

    private synchronized void LoginWithSession(String s, IRequestHandler d1)
    {
        MLog.d(TAG, (new StringBuilder("Login with existing session: ")).append(s).append(" - bootServer: ").append(i).append(" - appKey: ").append(mAppKey).toString());
        HttpRequest httprequest;
        (httprequest = createHttpRequest(false, ((StringNameValueMap) (null)))).addQueryParam("auth_token", s);
        doRequest(httprequest, createRequestHandlerWithJson(d1));
    }

    public final void LoginSgameAccount(String s, String s1, IRequestHandler d1)
    {
    	LoginSgameAccount handler = new LoginSgameAccount(s, s1, d1);
        Run(handler);
    }

    public final void LoginWithSocial(Social d1, String s, String s1, String s2, IRequestHandlerWithError f1)
    {
    	Login handler = new Login(d1, s, s1, s2, f1);
        Run(handler);
    }

    public final void Close()
    {
        CloseHandler l1 = new CloseHandler((byte)0);
        Run(l1);
    }

    public final void RegisterSession(CookieStore cookiestore, final AsyncHttpResponseHandler b1) //a
    {
        HttpRequest httprequest;
        (httprequest = createHttpRequest(false, ((StringNameValueMap) (null)))).setMethod("GET");
        Object obj = null;
        try
        {
        	SgameHttpClient g1 = createSgameHttpClient(cookiestore);
            String s = MakeCmdUrl.getSession(i, mAppKey);
            g1.setUrl(s);
            g1.Execute(httprequest, new AsyncHttpResponseHandler() {

                public final void onSuccess(String s)
                {
                    MLog.d(Connection.getTAG(), (new StringBuilder("Succesfully registered for session: ")).append(s).toString());
                    a.onSuccess(s);
                }

                public final void onFailure(Throwable throwable, String s)
                {
                    MLog.d(Connection.getTAG(), throwable.getMessage(), throwable);
                    a.onFailure(throwable, s);
                }

                final AsyncHttpResponseHandler a;
                final Connection b;

            
            {
                b = Connection.this;
                a = b1;
            }
            }
            );
            return;
        }
        // Misplaced declaration of an exception variable
        catch(Exception ex)
        {
            MLog.d(TAG, ex.getMessage(), ex);
        }
    }

    private void doRequest(HttpRequest httprequest, IRequestHandlerWithJson g1) //a
    {
        Object obj = null;
        try
        {
            BasicCookieStore basiccookiestore = new BasicCookieStore();
            SgameHttpClient g2 = createSgameHttpClient(((CookieStore) (basiccookiestore)));
            String s = MakeCmdUrl.getSession(i, mAppKey);
            g2.setUrl(s);
            httprequest.setMethod("POST");
            g2.Execute(httprequest, createResponseHandler(g1, ((CookieStore) (basiccookiestore))));
        }
        catch(InvalidCredentialsConfigurationException ex)
        {
            MLog.d(TAG, ex.getMessage(), ex);
            g1.onError(new Error(ErrorMap.MOBAGE_NOT_INITIALIZED, ex), null);
        }
    }

    private IRequestHandlerWithJson createRequestHandlerWithJson(final IRequestHandler d1) //c
    {
        return new IRequestHandlerWithJson() {

            public final void onComplete(SessionData sessiondata, Credentials credentials, CookieStore cookiestore)
            {
            	mHandler.onComplete(sessiondata, credentials, cookiestore);
            }

            public final void onError(Error error, JSONObject jsonobject)
            {
            	mHandler.onError(error);
            }

            final IRequestHandler mHandler;
            final Connection mConnection;

            
            {
            	mConnection = Connection.this;
                mHandler = d1;
            }
        }
        ;
    }

    private HttpResponseHandler createResponseHandler(final IRequestHandlerWithJson g1, final CookieStore cookiestore) //a
    {
        Connection k1 = this;
        return new HttpResponseHandler(k1) {

            public final void onSuccess(JSONObject jsonobject)
            {
            }

            public final void onFailure(Throwable throwable, String s)
            {
                MLog.e("MobageJsonHttpResponseHandler", (new StringBuilder("login request failure due to not connecting to the server: ")).append(throwable.getStackTrace()).toString());
                ErrorMap errormap = ErrorMap.NETWORK_UNAVAILABLE;
                if(s != null)
                    try
                    {
                        s = null;
                        if((new JSONObject(s)).getInt("error") == 503)
                            errormap = ErrorMap.TOO_MANY_FAILED_LOGIN_ATTEMPTS;
                    }
                    catch(JSONException _ex) { }
                Iterator item;
                for(item = Connection.getListRequestHandler(d).iterator(); item.hasNext(); ((IRequestHandler)item.next()).onError(new Error(errormap, throwable)));
                c.onError(new Error(errormap, throwable), null);
            }

            public final void onError(Error error, JSONObject jsonobject)
            {
                Connection.deleteCredentials(a);
                MLog.e("MobageJsonHttpResponseHandler", (new StringBuilder("login request failure: code=")).append(error.getCode()).append(" error: ").append(error.getDescription()).toString());
                for(Iterator iterator = Connection.getListRequestHandler(d).iterator(); iterator.hasNext(); ((IRequestHandler)iterator.next()).onError(error));
                c.onError(error, jsonobject);
            }

            final Connection a;
            final CookieStore b;
            final IRequestHandlerWithJson c;
            final Connection d;

            
            {
                a = d = Connection.this;
                b = cookiestore;
                c = g1;
            }
        }
;
    }

    public final void a(MBUUser mbuuser, IRequestHandler d1)
    {
    }

    public final void a(MBUUser mbuuser, Social d1, IRequestHandler d2)
    {
    }

    public final void Run(IRequestHandler d1)
    {
    	Register register = new Register(d1);
        Run(register);
    }

    private SgameHttpClient createSgameHttpClient(CookieStore cookiestore) //a
        throws InvalidCredentialsConfigurationException
    {
    	SgameHttpClient g1;
        g1 = mOauthRequestFactory.createRequest(mCredentials, cookiestore, null, mAppKey, mAppVersion, mSdkVersion).createHttpClient(1);
        g1.setCookieStore(cookiestore);
        return g1;
    }

    static void Finish(Connection k1, Runnable runnable)
    {
        k1.Finish(runnable);
    }

    static Credentials getCredentials(Connection k1) //a
    {
        return k1.mCredentials;
    }

    static boolean loadCredentials(Connection k1) //b
    {
        return k1.loadCredentials();
    }

    static void LoginWithSession(Connection k1, String s, IRequestHandler d1) //a
    {
        k1.LoginWithSession(s, d1);
    }

    static String getTAG() //b
    {
        return TAG;
    }

    static String getAppKey(Connection k1) //c
    {
        return k1.mAppKey;
    }

    static HttpRequest createHttpRequest(Connection k1, boolean flag, StringNameValueMap b1) //a
    {
        return k1.createHttpRequest(flag, b1);
    }

    static IRequestHandlerWithJson createRequestHandlerWithJson(Connection k1, IRequestHandler d1) //a
    {
        return k1.createRequestHandlerWithJson(d1);
    }

    static void doRequest(Connection k1, HttpRequest httprequest, IRequestHandlerWithJson g1) //a
    {
        k1.doRequest(httprequest, g1);
    }

    static SgameHttpClient createSgameHttpClient(Connection k1, CookieStore cookiestore) //a
        throws InvalidCredentialsConfigurationException
    {
        return k1.createSgameHttpClient(cookiestore);
    }

    static String d(Connection k1)
    {
        return k1.i;
    }

    static void deleteCredentials(Connection k1) //e
    {
        k1.deleteCredentials();
    }

    static StringNameValueMap a(Connection k1, MBUUser mbuuser)
    {
        StringNameValueMap b1;
        b1 = new StringNameValueMap();
        b1.Add("user[gamertag]", mbuuser.k());
        b1.Add("user[email]", mbuuser.getEmail());
        b1.Add("user[password]", mbuuser.getPassword());
        b1.Add("user[password_confirmation]", mbuuser.getPassword());
        b1.Add("user[age_restricted]", "0");
        b1.Add("user[motto]", "");
        b1.Add("user[birth_date]", "1906-4-0");
        b1.Add("user[opt_in]", mbuuser.h() ? "1" : "0");
        b1.Add("user[first_name]", mbuuser.getFirstName() != null ? mbuuser.getFirstName() : "");
        b1.Add("user[last_name]", mbuuser.getLastName() != null ? mbuuser.getLastName() : "");
        b1.Add("field", "gamertag");
        b1.Add("value", mbuuser.k());
        return b1;
    }

    static HttpResponseHandler createRequest(Connection k1, IRequestHandlerWithJson g1, CookieStore cookiestore) //a
    {
        return k1.createResponseHandler(g1, cookiestore);
    }

    static HttpRequest addSocialParams(HttpRequest httprequest, Social d1) //a
    {
        httprequest.addQueryParam("social_account[social_type]", d1.a());
        httprequest.addQueryParam("social_account[social_id]", d1.b());
        httprequest.addQueryParam("social_account[social_token]", d1.c());
        return httprequest;
    }

    static Context getContext(Connection k1) //g
    {
        return k1.mContext;
    }

    static void SaveCredentials(Connection k1) //h
    {
        k1.SaveCredentials();
    }

    static List<IReleaseHandler> getListReleaseHandler(Connection k1) //f
    {
        return k1.listL;
    }

    static List<IRequestHandler> getListRequestHandler(Connection k1) //i
    {
        return k1.listK;
    }

    private static String TAG = "USLoginRegHandler";
    private Credentials mCredentials;
    private String c;
    private String d;
    private ISgameHttpClientFactory mOauthRequestFactory;
    private String mAppKey;
    private String mAppVersion;
    private String mSdkVersion;
    private String i;
    private Context mContext;
    private List<IRequestHandler> listK; //k
    private List<IReleaseHandler> listL; //l
    private ArrayList m;

}
